<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <?= $show_code; ?>
        <title><?php echo $this->config->item('title_page'); ?></title>
    </head>
    <body>
        <div class="panel panel-default body-contain ">
            <div class="panel-heading"><span class="icon-g-barcode"></span>
                <strong> การจัดการรายการซื้อ (Purchase Management)</strong>
            </div>
            <div class="panel-body">
                <?php $this->load->view('contains/menu_module_bar'); ?>
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="panel panel-default">
                            <!-- Default panel contents -->
                            <div class="panel-heading"><strong>ค้นหาข้อมูลรายการซื้อ</strong></div>
                            <?php echo form_open('purchase/home/search', 'class="form-inline"  method="post"') ?>
                            <?php echo form_hidden('action', 'search') ?>
                            <div class="panel-body text-center" >
                                <p>
                                <div class="form-group margin-right">
                                    <label class="control-label">วันที่ทำรายการ</label>
                                    <?= $cmb_start_day; ?>
                                    <?= $cmb_start_month; ?>
                                    <?= $cmb_start_year; ?>
                                    <label class="control-label">ถึง</label>
                                    <?= $cmb_end_day; ?>
                                    <?= $cmb_end_month; ?>
                                    <?= $cmb_end_year; ?>
                                </div>
                            </div>
                            <div class="text-center margin-bottom">
                                <button type="submit" class="btn btn-default">
                                    <span class="glyphicon glyphicon-search"></span>
                                    <strong>ค้นหา</strong>
                                </button>
                                <button type="button" class="btn btn-default"  onclick="location.href = '<?= base_url(); ?>purchase/home'">
                                    <span class="icon-g-cleaning"></span>
                                    <strong>ล้างค่า</strong>
                                </button>
                            </div>
                            <?php echo form_close(); ?>
                            <ul class="nav nav-tabs"></ul>
                            <div class="pull-right">
                                <!--<button class="btn btn-success"><span class="glyphicon glyphicon-list-alt"></span> <strong>ประวัติการแก้ไข</strong></button>-->
                                <button class="btn btn-primary position-search-btn" onclick="location.href = '<?= base_url(); ?>purchase/add_purchase'"><span class="glyphicon glyphicon-file"></span> <strong>เพิ่มข้อมูล</strong></button>
                            </div>
                            <!-- Table -->

                            <table class="table table-condensed table-hover table-bordered imagetable">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>วันที่ทำรายการ</th>
                                        <th>จำนวนรายการ</th>
                                        <th>ราคารวม</th>
                                        <th>การจัดการ</th>
                                    </tr>
                                </thead>
                                <?php
                                $utility = new Config_utility();
                                $num_list = $num_list;
                                foreach ($result_list as $list) {
                                    ?>
                                    <tr>
                                        <td>
                                            <?= $num_list = $num_list + 1; ?>
                                        </td>
                                        <td>
                                            <?=
                                            $utility->convert_date($list->purchase_created_date, $utility->DAY) . "  " .
                                            $utility->month_to_string($utility->convert_date($list->purchase_created_date, $utility->MONTH)) . "  " .
                                            $utility->convert_date($list->purchase_created_date, $utility->YEAR);
                                            ?>
                                        </td>
                                        <td>
                                            <?= $list->count_list . ' รายการ'; ?>
                                        </td>
                                        <td>
                                            <?=  $utility->format_number($list->sum_price) . ' บาท'; ?>
                                        </td>
                                        <td>
                                            <button class="btn btn-default btn-sm" onclick="location.href = '<?= base_url(); ?>purchase/view_purchase?id=<?= $list->purchase_id ?>'">
                                                <span class="glyphicon glyphicon-eye-open"></span>
                                            </button>
                                        </td>
                                    </tr>
                                    <?php
                                }
                                ?>
                            </table>
                            <div class="panel-footer footprint-size">
                                <div class="pull-right">
                                    <?= $this->pagination->create_links(); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>
